<%--
  Date: 2017/7/10
  Time: 16:05
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/view/common/conmont.jspf" %>
<html>
<head>
    <script type="text/javascript">
      function getTabWindow() {
         var curTabWin = null;
         var curTab = parent.$('#tt').tabs('getSelected');
         if (curTab && curTab.find('iframe').length > 0) {
           curTabWin = curTab.find('iframe')[0].contentWindow;
         }
         return curTabWin;
         }
    </script>
    <title>修改</title>
    <script type="text/javascript">
        $(function() {
//          初始化数据 从tab-iframe 中 获取选中的数据
            var items = getTabWindow().$("#dg").datagrid('getSelections');
            if(items.length==1){
                var column = items[0];
                $('#ff').form('load',{
                    supId:column.supId,
                    supRemark:column.supRemark,
                    supName:column.supName,
                    supLinkman:column.supLinkman,
                    supPhone:column.supPhone
                });
            }else{
              alert("请选择 1 条需要修改的数据");
              return;
            }

            $("[name='supName']").validatebox({
                required : true,
                missingMessage : '请填写供应商！'
            });
            $("[name='supLinkman']").validatebox({
                required : true,
                missingMessage : '请填写出联系人！'
            });
            $("[name='supPhone']").validatebox({
                required : true,
                missingMessage : '请填写联系电话！'
            });
            //禁用验证
            $("#ff").form("disableValidation");



        $("#btn").click(function() {
                $("#ff").form("enableValidation");
                if ($("#ff").form("validate")) {
//                  表单参数自动序列化 提交
                    $('#ff').form('submit', {
                        url : '${webRoot}/supplier/updataSup',
                        onSubmit : function() {
                            return true;
                        },
                        success : function(count) {
                            //可以定义为对应消息框
                            if(count>0){
                                alert("成功");
                                parent.$("#win").window("close");
                                getTabWindow().$("#dg").datagrid("reload");
                                getTabWindow().$("#dg").datagrid("clearChecked");
                            }else {
                                alert("更新失败")
                            }

                        }
                    });

                }else {
                    alert("请完成输入");
                }

            });

        });
    </script>
</head>
<body>
<form id="ff" method="post">
    <div>
        <label for="supId">供应商编号:</label> <input type="text" name="supId" />
    </div>
    <div>
        <label for="supName">供应商:</label> <input type="text" name="supName" />
    </div>
    <div>
        <label for="supLinkman">联系人:</label> <input type="text"
                                                    name="supLinkman" />
    </div>
    <div>
        <label for="supPhone">联系电话:</label> <input type="text"
                                                   name="supPhone" />
    </div>
    <div>
        <label for="supAddress">联系地址:</label> <input type="text"
                                                     name="supAddress" />
    </div>
    <div>
        <label for="supPay">期初应付(元):</label> <input type="text"
                                                    name="supPay" />
    </div>
    <div>
        <label for="supType">供应商类型：</label>
        <select id="cc" class="easyui-combobox" name="supType" style="width:200px;">
            <c:forEach items="${applicationScope.sysParam.supType}" var="supType">
                <option value="${supType.key}">${supType.value}</option>
            </c:forEach>
        </select>
    </div>
    <div>
        <label for="supRemark">备注:</label>
        <textarea name="supRemark"></textarea>
    </div>
    <div>
        <input id="btn" type="button" value="提交" />
    </div>
</form>


</body>
</html>
